package day2;

import java.util.Scanner;

public class demo2 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int []cost=new int[n];
        for (int i = 0; i <n ; i++) {
            cost[i]= scanner.nextInt();
        }
        if(n<3){
            System.out.println(0);
        }else {
            int []ret=new int[n+1];
            ret[0]=0;
            ret[1]=0;
            for (int i = 2; i <n ; i++) {
          ret[i]=Math.min(ret[i-1]+cost[i-1],ret[i-2]+cost[i-2]);
            }
            System.out.println(Math.min(ret[n-1]+cost[n-1],ret[n-2]+cost[n-2]));

        }


    }
}
